#include <iostream>

using namespace std;


class Base
{
	public:
		virtual ~Base() { cout<<"~Base"<<endl;}
		Base() {cout<<"Base"<<endl;}
		
};

class Derived : public Base 
{
	public:
		virtual ~Derived() { cout<<"~Derived"<<endl;}
		Derived() { cout<<"Derived"<<endl;}
};

int main(void)
{
	Base b;
	Base *pb;
	Derived d;
	Derived *pd;
	pb = dynamic_cast<Base*> (&d);
	pd = dynamic_cast<Derived*> (&b);
	
	Base *pB = new Derived;
	delete pB;
	
	return 0;
}

